diff options
| author | Ariel Costas Guerrero <94913521+arielcostas@users.noreply.github.com> | 2024-05-04 01:05:04 +0200 |
|---|---|---|
| committer | Ariel Costas Guerrero <94913521+arielcostas@users.noreply.github.com> | 2024-05-04 13:34:10 +0200 |
| commit | fe7c149811f2e20c055ad0375aff05d29491efb4 (patch) | |
| tree | 8df0652a35cca0f9c8fcb5fb90648fef2f8415b4 /src/pages/blog/[slug].astro | |
| parent | 3de434508e0b609dea1ce8dca94ef1b708e61d61 (diff) | |
Rebuild the site in Astro
Add licence
Update site name in header to match README.md
Add missing metadescription, opengraph and link to RSS
Update Astro configuration to include sitemap integration with priority and changefreq settings
New post
Diffstat (limited to 'src/pages/blog/[slug].astro')
| -rw-r--r-- | src/pages/blog/[slug].astro | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/src/pages/blog/[slug].astro b/src/pages/blog/[slug].astro new file mode 100644 index 0000000..f9ceec1 --- /dev/null +++ b/src/pages/blog/[slug].astro @@ -0,0 +1,59 @@ +--- +import type { GetStaticPaths } from "astro"; +import Layout from "../../layouts/Layout.astro"; +import { getCollection } from "astro:content"; + +export const getStaticPaths = (async () => { + const entries = await getCollection("blog"); + return entries.map((entry) => ({ + params: { slug: entry.slug }, + props: { entry }, + })); +}) satisfies GetStaticPaths; + +const { entry } = Astro.props; +const { Content } = await entry.render(); + +const formattedDate = new Date(entry.data.publishedAt).toLocaleDateString( + "es-ES", + { + year: "numeric", + month: "long", + day: "numeric", + weekday: "long", + }, +); + +const schema = { + "@context": "https://schema.org", + "@type": "BlogPosting", + headline: entry.data.title, + datePublished: entry.data.publishedAt.toISOString(), + author: { + "@type": "Person", + name: "Ariel Costas Guerrero", + }, + publisher: { + "@type": "Person", + name: "Ariel Costas Guerrero", + logo: { + "@type": "ImageObject", + url: "https://www.costas.dev/favicon.png", + }, + }, +}; +--- + +<Layout title={entry.data.title} description={entry.data.metaDescription}> + <script type="application/ld+json" slot="head-jsonld" set:html={JSON.stringify(schema)}></script> + + <h1>{entry.data.title}</h1> + <small> + Publicado el + <time datetime={entry.data.publishedAt.toISOString()}> + {formattedDate} + </time> + </small> + + <Content /> +</Layout> |
